'use strict';

describe('Service: Backendservice', function () {

    // load the service's module
    beforeEach(module('homepageApp'));

    // instantiate service
    var Backendservice;
    var $httpBackend;
    beforeEach(inject(function (_$httpBackend_, _Backendservice_) {
        Backendservice = _Backendservice_;
        $httpBackend = _$httpBackend_;
    }));

    it('should do something', function () {
        expect(!!Backendservice).toBe(true);
    });

    it('should GET homepage images from the server', function () {
        $httpBackend.expectGET('dynamodbApi/getImagesForPage.php').respond(200);

        var imagesRetrieved = Backendservice.getImagesForPage();

        $httpBackend.flush();

        expect(imagesRetrieved).not.toBe(null);
    });

    it('should GET homepage posts from the server', function () {
        $httpBackend.expectGET('dynamodbApi/getPostsForPage.php').respond(200);

        var postsRetrieved = Backendservice.getPostsForPage();

        $httpBackend.flush();

        expect(postsRetrieved).not.toBe(null);
    });
});
